package org.ucas.faker.web.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;

@Table(name = "task_log", indexes = {
    @Index(name = "depot_index", columnList = "depot_id", unique = false),
    @Index(name = "user_index", columnList = "operator", unique = false),
    @Index(name = "depot_version_category", columnList = "depot_id,version,category",unique = false)
})
@Entity
public class TaskLog extends IdEntity {

  public static enum TaskStatus {
    CREATED,
    PROCESSING,
    FINISHED,
    CANCELED
  };

  public static enum TaskCategory {
    UPLOAD_DATA,
    GEN_FEATURE,
    GEN_REPORT,
    WX_SEARCH;

    @Override
    public String toString() {
      switch (this) {
        case UPLOAD_DATA:
          return "0";
        case GEN_FEATURE:
          return "1";
        case GEN_REPORT:
          return "2";
        case WX_SEARCH:
          return "3";
      }
      return null;
    }
  }

  @Column(name = "depot_id", nullable = true)
  private Long depotId;

  @Column(name = "version", nullable = true)
  private Long version; // 对专利库的哪个版本进行操作

  @Column(name = "operator", nullable = false)
  private Long operator;

  @Column(name = "status", nullable = false)
  private TaskStatus status;

  @Column(name = "category", nullable = false)
  private TaskCategory category;

  @Column(name = "progress", nullable = true)
  private Integer progress = 0;

  @Column(name = "attachment", nullable = true, columnDefinition = "VARCHAR(1000)")
  private String attachment;

  public Long getDepotId() {
    return depotId;
  }

  public void setDepotId(Long depotId) {
    this.depotId = depotId;
  }

  public Long getVersion() {
    return version;
  }

  public void setVersion(Long version) {
    this.version = version;
  }

  public Long getOperator() {
    return operator;
  }

  public void setOperator(Long operator) {
    this.operator = operator;
  }

  public TaskStatus getStatus() {
    return status;
  }

  public void setStatus(TaskStatus status) {
    this.status = status;
  }

  public TaskCategory getCategory() {
    return category;
  }

  public void setCategory(TaskCategory category) {
    this.category = category;
  }

  public Integer getProgress() {
    return progress;
  }

  public void setProgress(Integer progress) {
    this.progress = progress;
  }

  public String getAttachment() {
    return attachment;
  }

  public void setAttachment(String attachment) {
    this.attachment = attachment;
  }
  
  
}
